<template>
  <div>
    <el-dialog
      title="文档正文"
      width="80%"
      :visible.sync="dialogVisible"
      top="15vh"
      class="showDialogClass"
      :before-close="handleClose"
    >
      <div style="width:100%;height:700px;overflow-y:scroll">
        <p v-text="fileContent" />
      </div>
    </el-dialog>
  </div>
</template>

  <script>

  import { fileDetail } from "@/api/knowledge/fileBase";
  import store from "@/store";

  export default {
    name: `docPreviewPage`,
    data () {
      return {
        dialogVisible: false,
        loading: false,
        docId: ``,
        fileContent: ``,
      }
    },
    methods: {
      init (id) {
        this.dialogVisible = true;
        this.docId = id;
        this.getDocByid(id)
      },
      getDocByid (id) {
        const params = {
          'userId': store.getters.user_id.toString(),
          'token': store.getters.token.toString(),
          userName: store.getters.userName.toString(),
          "data": { "fileId": id },
        }
        fileDetail(params).then((data) => {
          if (data.result) {
            this.fileContent = data.resultdata.data.fileContent
            this.dialogVisible = true

          }

        })
      },
      handleClose () {
        this.cancel()
      },
      cancel () {
        this.dialogVisible = false
        // this.docUrl = ``;
      },
    },
  }
  </script>

  <style lang="scss">
  // .showDialogClass .el-dialog__body {
  //   padding: 0px 20px !important;
  // }
  </style>
